import { http } from "./http";
import type {
  categoriesParams,
  addGoodsRes,
  configs,
  EditConfigs,
  editGoodsRes,
  loginRes,
  listT,
  addSwiper,
  delSwiper,
  configsList,
  editSwiper,
  categoryList,
  addCategory,
  editCategory,
  delGoods,
  orderT,
  orderDetail,
  editAccount,
  editPwd,
  editGoods,
} from "../types/type";
const api = {
  // 登录
  loginApi: (params: loginRes) => http.post("/adminUser/login", params),
  // 个人信息
  profileApi: () => http.get("/adminUser/profile"),
  // 退出登录
  logoutApi: () => http.delete("/logout"),
  // 级联选择器
  categoriesApi: (params?: categoriesParams) =>
    http.get("/categories", { params }),
  // 上传图片 /upload/file
  uploadApi: (params: File) => http.post("/upload/file", params),
  // 添加商品 post  /goods
  addGoodsApi: (params: addGoodsRes) => http.post("/goods", params),
  // 轮播图配置 /carousels get
  carouselsApi: (params: listT) => http.get("/carousels", { params }),
  // 添加轮播图 /carousels post
  addCarouselsApi: (params: addSwiper) => http.post("/carousels", params),
  // 删除轮播图 /carousels delete ids:[]
  deleteCarouselsApi: (params: delSwiper) =>
    http.delete("/carousels", { data: params }),
  // 编辑轮播图 /carousels put
  editCarouselsApi: (params: editSwiper) => http.put("/carousels", params),
  //   商品配置 /indexConfigs get
  indexConfigsApi: (params: configsList) =>
    http.get("/indexConfigs", { params }),
  //   删除商品配置 /indexConfigs/delete post
  deleteIndexConfigsApi: (params: delSwiper) =>
    http.delete("/indexConfigs", { data: params }),
  //   添加商品配置 /indexConfigs post
  addIndexConfigsApi: (params: configs) => http.post("/indexConfigs", params),
  //   修改商品配置 /indexConfigs put
  editIndexConfigsApi: (params: EditConfigs) =>
    http.put("/indexConfigs", params),
  // 分类管理 /categories get
  getCategoriesApi: (params: categoryList) =>
    http.get("/categories", { params }),
  // 添加分类 /categories post
  addCategoriesApi: (params: addCategory) => http.post("/categories", params),
  // 编辑分类 /categories put
  editCategoriesApi: (params: editCategory) => http.put("/categories", params),
  // 删除分类 /categories delete
  deleteCategoriesApi: (params: delSwiper) =>
    http.delete("/categories", { data: params }),
  // 商品管理列表 goods/list get
  getGoodsListApi: (params: listT) => http.get("/goods/list", { params }),
  // 下架商品 /goods/status/1 put
  OffShelfGoodsApi: (params: delGoods) =>
    http.put("/goods/status/" + params.status, { ids: params.ids }),
  // 编辑商品  /goods put
  editGoodsApi: (params: editGoodsRes) => http.put("/goods", params),
  // 会员管理 /users get
  getUsersListApi: (params: listT) => http.get("/users", { params }),
  // 解除禁用 禁用 /users/1 put
  disableUsersApi: (params: delGoods) =>http.put("/users/" + params.status, { ids: params.ids }),
  // 订单管理列表 /orders get
  getOrdersListApi: (params: orderT) =>http.get("/orders", { params }),
  // 关闭订单 /orders/close put
  closeOrdersApi: (params: delSwiper) =>http.put("/orders/close", { ids: params.ids }),
  // 配货完成 /orders/checkDone put
  checkDoneApi: (params: delSwiper) =>http.put("/orders/checkDone", { ids: params.ids }),
  // 出货完成 /orders/checkOut put
  checkOutApi: (params: delSwiper) =>http.put("/orders/checkOut", { ids: params.ids }),
  // 订单详情接口 /orders/29911 get
  getOrderDetailApi: (params: orderDetail) => http.get("/orders/" + params.id),
  // 修改账户 /adminUser/name put
  editAdminUserApi: (params: editAccount) =>http.put("/adminUser/name", params),
  // 修改密码 /adminUser/password put
  editAdminUserPasswordApi: (params: editPwd) =>http.put("/adminUser/password", params),
  // 编辑商品回调接口
  editProductCallbackApi: (params: editGoods) =>http.get("/goods/" + params.id),
};
export { api };
